let express = require('express');
require('dotenv').config()
let path = require('path');
let cookieParser = require('cookie-parser');
let logger = require('morgan');
const {RagService} = require('./core/rag/index');


let indexRouter = require('./routes/index');

let app = express();

// 初始化RAG服务
RagService.init().catch(error => {
  console.error('RAG服务初始化失败:', error);
});

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);

module.exports = app;
